package com.example.common.utils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class ClassUtils {

    public static Field[] getFields(Class<?> clazz){

        return clazz.getDeclaredFields();
    }

    public static List<String> getFieldNames(Class<?> clazz){
        List<String> fieldNames = new ArrayList<>();
        Field[] fields = getFields(clazz);
        for (Field field:fields){
            fieldNames.add(getFieldName(field));
        }

        return fieldNames;
    }

    public static String getFieldName(Field field){
        field.setAccessible(true);
        return field.getName();
    }
    
}
